import { Response } from "express";

/**
 * @param res {Response}
 * @param data [] 返回数据
 * @param msg string 
 * @param code number
 */
function success(res: Response, data: any = [], message: string = 'success', code: number = 200) {
  res.status(code).send({
    code,
    message,
    data
  })
}

/** 
 * @param res {Response}
 * @param data [] 返回数据
 * @param msg string 
 * @param code number
 */
function error(res: Response, data: any = [], message: string = 'error', code: number = 400) {
  res.status(code).send({
    code,
    message,
    data
  })
}

export default { success, error }